// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   ADXPImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.datatypes.ADXP;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;



// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            STCommonImpl, ANYImpl, BLImpl, CSImpl, 
//            NullFlavorImpl, TYPEImpl

public class ADXPImpl extends STCommonImpl
    implements ADXP
{

    public static final String RCS_ID = "$Header: ADXPImpl.java 115.32 2005/09/16 09:22:55 amchanda noship $";
    protected CS _partType;
    private static final ADXP nullNI = new ADXPImpl(CSImpl.valueOf("NI"));
    private static final ADXP nullOTH = new ADXPImpl(CSImpl.valueOf("OTH"));
    private static final ADXP nullNINF = new ADXPImpl(CSImpl.valueOf("NINF"));
    private static final ADXP nullPINF = new ADXPImpl(CSImpl.valueOf("PINF"));
    private static final ADXP nullUNK = new ADXPImpl(CSImpl.valueOf("UNK"));
    private static final ADXP nullASKU = new ADXPImpl(CSImpl.valueOf("ASKU"));
    private static final ADXP nullNAV = new ADXPImpl(CSImpl.valueOf("NAV"));
    private static final ADXP nullMSK = new ADXPImpl(CSImpl.valueOf("MSK"));
    private static final ADXP nullNA = new ADXPImpl(CSImpl.valueOf("NA"));
    private static final ADXP nullNASK = new ADXPImpl(CSImpl.valueOf("NASK"));

    public static ADXP valueOf(String s, CS cs)
    {
        if(s == null || s.length() == 0)
            throw ANYImpl.newNullException("ADXP", "valueOf", "value");
        else
            return new ADXPImpl(s, cs);
    }

    protected ADXPImpl(String s, CS cs)
    {
        super(s);
        _partType = cs;
    }

    protected ADXPImpl(CS cs)
    {
        super(cs);
        _partType = CSImpl.nullCS(NullFlavorImpl.NI);
    }

    public CS partType()
    {
        if(isNull().isTrue())
            return CSImpl.nullCS(NullFlavorImpl.NI);
        else
            return _partType;
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.ADXP;
    }

    public BL equal(ANY any)
    {
        if(!(any instanceof ADXP))
            return BLImpl.FALSE;
        ADXP adxp = (ADXP)any;
        if(isNull().or(any.isNull()).isTrue())
        {
            return BLImpl.FALSE;
        } else
        {
            BL bl = BLImpl.valueOf(stringValue().equals(adxp.stringValue()));
            bl = partType().isNull().isFalse() ? bl.and(partType().equal(adxp.partType())) : bl.and(adxp.partType().isNull());
            return bl;
        }
    }

    public int hashCode()
    {
        int i = 17;
        if(isNull().isFalse())
        {
            i = 37 * i + _value.hashCode();
            i = 37 * i + (_partType != null ? _partType.hashCode() : 0);
        }
        return i;
    }

//    public XMLNode[] writeXML(XMLDocument xmldocument, String s)
//        throws Hl7Exception
//    {
//        try
//        {
//            XMLElement xmlelement = null;
//            if(partType() != null && partType().isNull().isFalse())
//            {
//                if(partType().code().stringValue().equals("CNT"))
//                    xmlelement = (XMLElement)xmldocument.createElement("country");
//                if(partType().code().stringValue().equals("STA"))
//                    xmlelement = (XMLElement)xmldocument.createElement("state");
//                if(partType().code().stringValue().equals("CPA"))
//                    xmlelement = (XMLElement)xmldocument.createElement("county");
//                if(partType().code().stringValue().equals("CTY"))
//                    xmlelement = (XMLElement)xmldocument.createElement("city");
//                if(partType().code().stringValue().equals("ZIP"))
//                    xmlelement = (XMLElement)xmldocument.createElement("postalCode");
//                if(partType().code().stringValue().equals("SAL"))
//                    xmlelement = (XMLElement)xmldocument.createElement("streetAddressLine");
//                if(partType().code().stringValue().equals("DEL"))
//                    xmlelement = (XMLElement)xmldocument.createElement("delimiter");
//                if(partType().code().stringValue().equals("STR"))
//                    xmlelement = (XMLElement)xmldocument.createElement("streetName");
//                if(partType().code().stringValue().equals("BNR"))
//                    xmlelement = (XMLElement)xmldocument.createElement("houseNumber");
//                if(partType().code().stringValue().equals("DIR"))
//                    xmlelement = (XMLElement)xmldocument.createElement("direction");
//                if(partType().code().stringValue().equals("ADL"))
//                    xmlelement = (XMLElement)xmldocument.createElement("additionalLocator");
//                if(partType().code().stringValue().equals("POB"))
//                    xmlelement = (XMLElement)xmldocument.createElement("postBox");
//                if(partType().code().stringValue().equals("CEN"))
//                    xmlelement = (XMLElement)xmldocument.createElement("censusTract");
//                if(partType().code().stringValue().equals("BNN"))
//                    xmlelement = (XMLElement)xmldocument.createElement("houseNumberNumeric");
//                if(partType().code().stringValue().equals("CAR"))
//                    xmlelement = (XMLElement)xmldocument.createElement("carrier");
//                if(partType().code().stringValue().equals("STB"))
//                    xmlelement = (XMLElement)xmldocument.createElement("streetNameBase");
//                if(partType().code().stringValue().equals("STTYP"))
//                    xmlelement = (XMLElement)xmldocument.createElement("streetNameType");
//                if(partType().code().stringValue().equals("UNID"))
//                    xmlelement = (XMLElement)xmldocument.createElement("unitID");
//                if(partType().code().stringValue().equals("UNIT"))
//                    xmlelement = (XMLElement)xmldocument.createElement("unitType");
//                if(xmlelement != null)
//                {
//                    xmlelement.setAttribute("partType", partType().code().stringValue());
//                    xmlelement.setAttribute("encoding", "TXT");
//                    String s1 = stringValue();
//                    if(s1 != null)
//                    {
//                        org.w3c.dom.Text text = xmldocument.createTextNode(s1);
//                        xmlelement.appendChild(text);
//                    }
//                }
//            }
//            XMLNode axmlnode[] = new XMLNode[1];
//            axmlnode[0] = xmlelement;
//            return axmlnode;
//        }
//        catch(Exception exception)
//        {
//            throw new Hl7Exception(exception);
//        }
//    }

    public static ADXP nullADXP(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

	public byte[] byteArray() {
		// TODO Auto-generated method stub
		return null;
	}

}
